<template>
  <div id="app">
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>
    <div style="height: 3.8rem"></div>
    <van-tabbar
      v-model="active"
      safe-area-inset-bottom
      @change="onChange"
    >
      <van-tabbar-item replace to="/" icon="gift-o">礼品商城</van-tabbar-item>
      <van-tabbar-item replace to="/member" icon="phone-o"
        >商家登记</van-tabbar-item
      >
      <van-tabbar-item replace to="/question" icon="bar-chart-o"
        >投票</van-tabbar-item
      >
      <van-tabbar-item replace to="/card" icon="user-o"
        >会员中心</van-tabbar-item
      >
    </van-tabbar>
  </div>
</template>

<script>
import { mapGetters, mapActions } from "vuex";
export default {
  name: "app",
  data() {
    return {
      
      transitionName: "slide-right",
      active: +sessionStorage.getItem("tabBarActive"),
    };
  },
  computed: {
    ...mapGetters(["tabBarActive"]),
  },

  created() {
    // this.active = this.tabBarActive;
    // console.log(this.tabBarActive);
  },
  methods: {
    ...mapActions(["setTabBarActive"]),
    onChange(active) {
      this.setTabBarActive(active);
    },
  },
  watch:{
    tabBarActive(val){
      this.active = val;
    }
  }
};
</script>

<style lang="scss">
</style>
